﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true"
    CodeBehind="AdminDepatments.aspx.cs" Inherits="FlowersStore.AdminDepatments" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>       
        <h2 class="AdminPart">
            Разделы</h2>
    </div>
    <div>
        <asp:ListView ID="ListView1" runat="server" DataKeyNames="Department_id" DataSourceID="LinqDataSource1"
            InsertItemPosition="LastItem">
            <AlternatingItemTemplate>
                <tr style="background-color: #FFF8DC;">                    
                    <td>
                        <asp:Label ID="Department_nameLabel" runat="server" Text='<%# Eval("Department_name") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Department_descriptionLabel" runat="server" Text='<%# Eval("Department_description") %>' />
                    </td>
                    <td>
                        <asp:HyperLink ID="HyperLink1" NavigateUrl='<%# "~/AdminCategories.aspx?dept="+Eval("Department_id") %>'
                            runat="server">
                        Редактировать категории
                        </asp:HyperLink>
                    </td>
                    <td>
                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Удалить" />
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Редактировать" />
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <EditItemTemplate>
                <tr style="background-color: #008A8C; color: #FFFFFF;">                    
                    <td>
                        <asp:TextBox ID="Department_nameTextBox2" runat="server" Text='<%# Bind("Department_name") %>' />
                        <asp:RequiredFieldValidator ID="editValidator" ControlToValidate="Department_nameTextBox2"
                            runat="server" Display="Dynamic" ValidationGroup="EditItemTemplate" ErrorMessage="*" />
                    </td>
                    <td>
                        <asp:TextBox TextMode="MultiLine" ID="Department_descriptionTextBox" runat="server"
                            Text='<%# Bind("Department_description") %>' />
                    </td>
                    <td>
                        
                    </td>
                    <td>
                        <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Изменить"
                            CausesValidation="true" ValidationGroup="EditItemTemplate" />
                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Отмена" CausesValidation="false" />
                    </td>
                </tr>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <table id="Table1" runat="server" style="background-color: #FFFFFF; border-collapse: collapse;
                    border-color: #999999; border-style: none; border-width: 1px;">
                    <tr>
                        <td>
                           Таблица пуста
                        </td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <InsertItemTemplate>
                <tr style="">                   
                    <td>
                        <asp:TextBox ID="Department_nameTextBox" runat="server" Text='<%# Bind("Department_name") %>' />
                        <asp:RequiredFieldValidator ID="insertValidator" ControlToValidate="Department_nameTextBox"
                            runat="server" Display="Dynamic" ValidationGroup="InsertItemTemplate" ErrorMessage="*" />
                    </td>
                    <td>
                        <asp:TextBox TextMode="MultiLine" ID="Department_descriptionTextBox" runat="server"
                            Text='<%# Bind("Department_description") %>' />
                    </td>
                     <td>
                        <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Добавить"
                            CausesValidation="true" ValidationGroup="InsertItemTemplate" />
                        <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Очистить" />
                    </td>
                </tr>
            </InsertItemTemplate>
            <ItemTemplate>
                <tr style="background-color: #DCDCDC; color: #000000;">                   
                    <td  class="AdminTabCell">
                        <asp:Label ID="Department_nameLabel" runat="server" Text='<%# Eval("Department_name") %>' />
                    </td>
                    <td>
                        <asp:Label ID="Department_descriptionLabel" runat="server" Text='<%# Eval("Department_description") %>' />
                    </td>
                    <td  class="AdminTabCell">
                        <asp:HyperLink ID="HyperLink1" NavigateUrl='<%# "~/AdminCategories.aspx?dept="+Eval("Department_id") %>'
                            runat="server">
                        Редактировать категории
                        </asp:HyperLink>
                    </td>
                     <td  class="AdminTabCell">
                        <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Удалить" />
                        <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Редактировать" />
                    </td>
                </tr>
            </ItemTemplate>
            <LayoutTemplate>
                <table id="Table2" runat="server">
                    <tr id="Tr1" runat="server">
                        <td id="Td1" runat="server">
                            <table class="AdminTable" id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;
                                border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
                                font-family: Verdana, Arial, Helvetica, sans-serif;">
                                <tr id="Tr2" runat="server" style="background-color: #DCDCDC; color: #000000;">                                   
                                    <th id="Th1" class="AdminTabTopLineCell" runat="server">
                                        Название раздела
                                    </th>
                                    <th id="Th2" class="AdminTabTopLineCell" runat="server">
                                        Описание
                                    </th>
                                    <th id="Th3" class="AdminTabTopLineCell" runat="server">
                                        Категории
                                    </th>
                                     <th id="Th4" class="AdminTabTopLineCell" runat="server">
                                    </th>
                                </tr>
                                <tr id="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr id="Tr3" runat="server">
                        <td id="Td2" runat="server" style="text-align: center; background-color: #FFF8DC; font-family: Verdana, Arial, Helvetica, sans-serif;
                            color: #000000;">
                            <asp:DataPager ID="DataPager1" runat="server">
                                <Fields>
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" NextPageText="След." LastPageText="Последняя" FirstPageText="Первая" PreviousPageText="Перд." />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
        </asp:ListView>
        <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="FlowersStore.FlowerStoreDataContext"
            EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntityTypeName=""
            TableName="Departments">
        </asp:LinqDataSource>
    </div>
</asp:Content>
